package com.my.chapter12;

public class practice18 {
    public static void main(String[] args) {
        try {
            LostMessage lm = new LostMessage();
            try {
                try {
                    lm.f();
                } finally {
                    lm.dispose();
                }
            } finally {
                lm.cleanup();
            }
        } catch(Exception e) {
            System.out.println(e);
        }
    }
}

class VeryImportantException extends Exception{
    @Override
    public String toString() {
        return "A very important exception";
    }
}

class HoHumException extends Exception{
    @Override
    public String toString() {
        return "A trivial exception";
    }
}

class YetAnotherException extends Exception {
    public String toString() {
        return "Yet another exception";
    }
}

class LostMessage {
    void f() throws VeryImportantException {
        throw new VeryImportantException();
    }
    void dispose() throws HoHumException {
        throw new HoHumException();
    }
    void cleanup() throws YetAnotherException {
        throw new YetAnotherException();
    }
}

